package cn.itsource.org.domain;

import cn.itsource.basic.domain.BaseDomain;
import cn.itsource.basic.domain.CreatePassword;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;

//用户
@Data
@Table(name = "t_user")
public class User extends BaseDomain implements CreatePassword {

    /**
     * 规则解耦
     */
    public interface PhoneRegister{}
    public interface EmailRegister{}

    private String username;
    @NotBlank(message = "邮箱为空",groups = {EmailRegister.class})
    private String email;
    @NotBlank(message = "手机号为空",groups = {PhoneRegister.class})
    private String phone;
    private String salt;
    @NotBlank(message = "密码为空",groups = {PhoneRegister.class,EmailRegister.class})
    @Size(min = 3,message = "密码最少3位",groups = {PhoneRegister.class,EmailRegister.class})
    private String password;
    //1:正常 0:封号
    private Integer state = 1;
    private Integer age;
    private Date createtime = new Date();
    private String head_img;

    //验证码
    @Transient
    private String code;

    //密码确认
    @Transient
    private String configPassword;

}
